package com.bjpowernode.boss.mvc.models;

import com.bjpowernode.boss.common.enums.ResponseCode;
import lombok.Data;

@Data
public class AjaxResult {
    private Integer code;
    private String msg;
    private Object data;


    public static AjaxResult ok(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(ResponseCode.OK.getNumber());
        ajaxResult.setMsg(ResponseCode.OK.getMsg());
        ajaxResult.setData(data);
        return ajaxResult;
    }

    public static AjaxResult ok(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(ResponseCode.OK.getNumber());
        ajaxResult.setMsg(ResponseCode.OK.getMsg());
        ajaxResult.setData("");
        return ajaxResult;
    }
    public static AjaxResult fail(ResponseCode code){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(code.getNumber());
        ajaxResult.setMsg(code.getMsg());
        ajaxResult.setData("");
        return ajaxResult;
    }

}
